package myadmin.jtthink.com.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import myadmin.jtthink.com.Models.RoleAccessModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleAccessMapper extends BaseMapper<RoleAccessModel> {
    @Select(" select b.id,a.id as role_id,a.role_name,b.access_id,c.access_name " +
            "from role a left join role_access b on a.id=b.role_id left join access c  " +
            " on   b.access_id=c.id where   a.id=#{id}")
    public List<RoleAccessModel> getRoleAccess(@Param("id") int id);

    @Select(" select concat('ROLE_',upper(c.role_name)) as role_name,e.access_name from " +
            "ruser a,user_role b ,role c ,role_access d ,access e "+
            "where a.user_id=b.user_id and b.role_id=c.id " +
            "and c.id=d.role_id and d.access_id=e.id " +
            "and  a.user_name=#{userName} and status=1 ")
    List<RoleAccessModel> getUserRoleAccess(@Param("userName") String uname);
}
